package cn.cj.erp.bo.system;

import cn.cj.erp.common.SearchParam;
import cn.cj.erp.common.annotation.Search;
import cn.cj.erp.common.enums.SearchType;
import cn.cj.erp.common.enums.StatusEnum;
import cn.cj.erp.common.excel.anno.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.poi.ss.usermodel.HorizontalAlignment;

import java.util.Date;

/**
 * 系统访问记录表 sys_login_log
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SysLoginLogBo extends SearchParam {
    /** ID */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /** 用户账号 */
    @Excel(name = "用户账号")
    @Search(type = SearchType.LIKE)
    private String username;

    /** 登录状态 */
    @Excel(name = "登录状态")
    @Search(type = SearchType.EQ)
    private StatusEnum status;

    /** 登录IP地址 */
    @Excel(name = "登录地址")
    @Search(type = SearchType.LIKE)
    private String ip;

    /** 浏览器类型 */
    @Excel(name = "浏览器")
    private String browser;

    /** 操作系统 */
    @Excel(name = "操作系统")
    private String os;

    /** 提示消息 */
    @Excel(name = "提示消息", align = HorizontalAlignment.LEFT)
    @Search(type = SearchType.LIKE)
    private String msg;

    /** 登录时间（默认倒序排序） */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Search(defaultSortField = true)
    private Date loginTime;

    /** 登录时间开始，仅搜索 */
    @Search(type = SearchType.BETWEEN_BEGIN, fieldName = "login_time")
    private Date beginTime;

    /** 登录时间结束，仅搜索 */
    @Search(type = SearchType.BETWEEN_END, fieldName = "login_time")
    private Date endTime;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date modifyTime;
}
